/*
 * CollageApp.java
 */

package collage;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import javax.swing.JFrame;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class CollageApp extends SingleFrameApplication {

    /**
     * At startup create and show the main frame of the application.
     */
    @Override protected void startup() {
        try{
            CollageView collageView = new CollageView(this);
            JFrame mainFrame = collageView.getFrame();
            show(collageView);
            
            // maximizes the window
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            if (toolkit.isFrameStateSupported(JFrame.MAXIMIZED_BOTH)) {
                mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
            } else {
               Dimension screenSize = toolkit.getScreenSize();
               mainFrame.setLocation(0, 0);
               mainFrame.setSize(screenSize);
            }            
            
            collageView.initActionToolBar();
                    
            collageView.initCanvas();
               
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of CollageApp
     */
    public static CollageApp getApplication() {
        return Application.getInstance(CollageApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        
        launch(CollageApp.class, args);
    }
}
